package com.itheima.service.impl;

import com.itheima.mapper.EmpMapper;
import com.itheima.mapper.StudentMapper;
import com.itheima.pojo.ClazzOption;
import com.itheima.pojo.JobOption;
import com.itheima.service.ReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;


@Service
public class ReportServiceImpl implements ReportService {
    @Autowired
    private EmpMapper empMapper;
    @Autowired
    private StudentMapper studentMapper;
    @Override
    public JobOption getEmpJobData() {
        List<Map<String,Object>> list=empMapper.countEmpJobData();
        List<Object> jobList= list.stream().map(map->map.get("jobname")).toList();
        List<Object> dataList= list.stream().map(map->map.get("total")).toList();
        return new JobOption(jobList,dataList);
    }

    @Override
    public List<Map> countByGender() {
         return empMapper.countByGender();
    }

    @Override
    public List<Map> countByDegree() {
        return studentMapper.countByDegree();
    }

    @Override
    public ClazzOption countStudent() {
        List<Map> clazzList=studentMapper.countStudent();
        List<String> clazzname = clazzList.stream().map(map -> map.get("clazzname").toString()).toList();
        List<Object> total = clazzList.stream().map(map -> map.get("total")).toList();
        return new ClazzOption(clazzname,total);

    }


}
